// nodes/EndNode.js
import { CircleNode, CircleNodeModel } from '@logicflow/core'

class EndNodeModel extends CircleNodeModel {
  initNodeData(data) {
    super.initNodeData(data)
    this.r = 30
    this.text = {
      value: '结束',
      x: data.x,
      y: data.y + 40
    }
    // 结束节点只有入边
    this.targetRules.push({
      message: '结束节点只能连接入边',
      validate: (sourceNode, targetNode, sourceAnchor, targetAnchor) => {
        return sourceNode.type !== 'end-node'
      }
    })
  }
  
  getNodeStyle() {
    const style = super.getNodeStyle()
    style.fill = '#52c41a'
    style.stroke = '#389e0d'
    return style
  }
}

class EndNodeView extends CircleNode {}

export default {
  type: 'end-node',
  view: EndNodeView,
  model: EndNodeModel
}